home *** CD-ROM | disk | FTP | other *** search
/ Developer CD Series 1996 July: Mac OS SDK / Dev.CD Jul 96 SDK / Dev.CD Jul 96 SDK1.toast / Development Kits (Disc 1) / OpenDoc / OpenDoc Development / Debugging Support / OpenDoc Source Code / Storage / Bento / FSHdr.h < prev    next >
Encoding:
C/C++ Source or Header  |  1996-04-22  |  4.6 KB  |  150 lines  |  [TEXT/MPS ]

  1. /*
  2.     File:        FSHdr.h
  3.  
  4.     Contains:    ODFSContainer header
  5.  
  6.     Written by:    Vincent Lo
  7.  
  8.     Copyright:    © 1993 - 1995 by Apple Computer, Inc., all rights reserved.
  9.  
  10.     Change History (most recent first):
  11.  
  12.          <6>      4/7/95    EL        1225905: More ModDate stuff to container.
  13.          <5>     3/24/95    EL        1225905: Move state information such as mod
  14.                                     date from plfmFile to here
  15.          <4>     3/10/95    EL        1223465: allocate buffer on the heap.
  16.          <3>     2/10/95    VL        1205627: Added fMode to store access mode.
  17.          <2>     1/31/95    EL        1213321: Buffer the Bento file I/O.
  18.          <1>     5/27/94    VL        first checked in
  19.  
  20.     To Do:
  21. */
  22.  
  23. #ifndef _FSHDR_
  24. #define _FSHDR_
  25.  
  26. #ifndef _PLFMDEF_
  27. #include "PlfmDef.h"
  28. #endif
  29.  
  30. #ifndef _ODTYPES_
  31. #include "ODTypes.h"
  32. #endif
  33.  
  34. #ifndef _BENTOHDR_
  35. #include "BentoHdr.h"
  36. #endif
  37.  
  38. #ifndef __CM_API__
  39. #include "CMAPI.h"
  40. #endif
  41.  
  42. #ifndef __CM_API_TYPES__
  43. #include "CMAPITyp.h"
  44. #endif
  45.  
  46. #ifndef _PLFMDEF_
  47. #include "PlfmDef.h"
  48. #endif
  49.  
  50. //==============================================================================
  51. // Theory of Operation
  52. //==============================================================================
  53.  
  54. //==============================================================================
  55. // Constants
  56. //==============================================================================
  57.  
  58. extern const ODType    kODBentoFileTypeName; // = "FileCtr";
  59.  
  60. #define MininumChunkSize         0x100    /* minimum size of file space allocation    */
  61. #define DefaultChunkSize         0x800    /* default size of file space allocation    */
  62.  
  63. //==============================================================================
  64. // Scalar Types
  65. //==============================================================================
  66.  
  67. struct ContainerLabelFmt {            /* Layout of a container label:            */
  68.  ODUByte magicBytes[8];                /* 8 bytes: the magic byte identifier    */
  69.  ODUShort flags;                    /* 2    the label flag                    */
  70.  ODUShort bufSize;                    /* 2    TOC buffer size / 1024            */
  71.  ODUShort majorVersion;                /* 2    major format version number        */
  72.  ODUShort minorVersion;                /* 2    minor format version number        */
  73.  ODULong tocOffset;                    /* 4    offset to start of TOC            */
  74.  ODULong tocSize;                    /* 4    total byte size of the TOC        */
  75. };
  76. typedef struct ContainerLabelFmt ContainerLabelFmt;
  77.  
  78. //==============================================================================
  79. // Classes defined in this interface
  80. //==============================================================================
  81. class ODFSBentoHandlers;
  82.  
  83. //==============================================================================
  84. // Classes used by this interface
  85. //==============================================================================
  86. class PlatformFile;
  87.  
  88. //==============================================================================
  89. // ODFSBentoHandlers
  90. //==============================================================================
  91.  
  92. class ODFSBentoHandlers : public ODBentoHandlers
  93. {
  94. public:
  95.  
  96.     ODFSBentoHandlers(CMSession session, PlatformFile* file);
  97.     ODVMethod ~ODFSBentoHandlers();
  98.     
  99.     ODMethod void Initialize();
  100.     ODMethod CMSession GetCMSession();
  101.     
  102.     ODMethod CMRefCon OpenHandler(CMOpenMode mode);
  103.     ODMethod void CloseHandler();
  104.     ODMethod CMSize FlushHandler();
  105.     ODMethod CMSize SeekHandler(CM_LONG posOff, CMSeekMode mode);
  106.     ODMethod CMSize TellHandler();
  107.     ODMethod CMSize ReadHandler(CMPtr buffer, CMSize elementSize, CMCount theCount);
  108.     ODMethod CMSize WriteHandler(CMPtr buffer, CMSize elementSize, CMCount theCount);
  109.     ODMethod CMEofStatus EOFHandler();
  110.     ODMethod CMBoolean TruncHandler(CMSize containerSize);
  111.     ODMethod CMSize ContainerSizeHandler();
  112.     ODMethod void ReadLabelHandler(CMMagicBytes magicByteSequence,
  113.                         CMContainerFlags *flags, CM_USHORT *bufSize,
  114.                         CM_USHORT *majorVersion, CM_USHORT *minorVersion,
  115.                         CMSize *tocOffset, CMSize *tocSize);
  116.     ODMethod void WriteLabelHandler(CMMagicBytes magicByteSequence,
  117.                         CMContainerFlags flags, CM_USHORT bufSize,
  118.                         CM_USHORT majorVersion, CM_USHORT minorVersion,
  119.                         CMSize tocOffset, CMSize tocSize);
  120.     ODMethod CMValue ReturnParentValueHandler();
  121.     ODMethod CM_UCHAR* ReturnContainerNameHandler();
  122.     ODMethod CMType ReturnTargetTypeHandler(CMContainer container);
  123.     ODMethod void ExtractDataHandler(CMDataBuffer buffer,
  124.                             CMSize size, CMPrivateData data);
  125.     ODMethod void FormatDataHandler(CMDataBuffer buffer,
  126.                             CMSize size,
  127.                             CMPrivateData data);
  128.  
  129. private:
  130.  
  131.     ODMethod    void ReloadBuffer();
  132.     ODMethod    void FlushBuffer();
  133.  
  134.     CMSession    fSession;
  135.     PlatformFile*    fFile;
  136.     ODBoolean    fReverseEndian;
  137.     ODULong        fLogicalPos;
  138.     ODULong        fFileSize;
  139.     ODULong        fPhysicalFileSize;
  140.     ODULong        fWriteLimit;
  141.     ODULong        fChunkSize;
  142.     ODBoolean    fBufferDirty;
  143.     ODBoolean    fOpenReadOnly;
  144.     ODBoolean    fHasLabel;
  145.     ODULong        fBufferBegin;
  146.     ODSByte*    fBuffer;
  147.     ContainerLabelFmt fLabel;
  148. };
  149.  
  150. #endif // _FSHDR_